"""Definition of the lookjob content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

# -*- Message Factory Imported Here -*-
from my315ok.xtinfocontent import xtinfocontentMessageFactory as _

from my315ok.xtinfocontent.interfaces import Ilookjob
from my315ok.xtinfocontent.config import PROJECTNAME

lookjobSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-
 

   atapi.StringField(
        'name',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"name"),
            description=_(u""),
        ),
    ),
    atapi.StringField(
        'sex',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.gender",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"sex"),
            description=_(u""),
        ),
        required=True,
    ),
   atapi.DateTimeField(
        'born',
        storage=atapi.AnnotationStorage(),
        widget=atapi.CalendarWidget(
            label=_(u"born date"),
            description=_(u""),
        ),
        validators=('isValidDate'),
    ),
    atapi.StringField(
        'position',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.workposition",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"position"),
            description=_(u""),
        ),
    ),

     atapi.StringField(
        'polity',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.polity",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"polity"),
            description=_(u""),
        ),
    ),
     atapi.StringField(
        'eon',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.educationstatus",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"education"),
            description=_(u""),
        ),
    ),
    atapi.StringField(
        'phone',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"phone number"),
            description=_(u""),
        ),
    ),
 atapi.StringField(
        'mail',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"mail address"),
            description=_(u""),
        ),
        validators=('isEmail'),
    ),
 atapi.StringField(
        'salary',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.salary",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"expect salary"),
            description=_(u""),
        ),
    ),

      atapi.TextField(
        'resume',
        storage=atapi.AnnotationStorage(),
        default_output_type = 'text/html',
        widget=atapi.RichWidget(
            label=_(u"resume"),
            description=_(u""),
        ),
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

lookjobSchema['title'].storage = atapi.AnnotationStorage()
lookjobSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(lookjobSchema, moveDiscussion=False)


class lookjob(base.ATCTContent):
    """look for a job"""
    implements(Ilookjob)

    meta_type = "lookjob"
    schema = lookjobSchema
    _at_rename_after_creation = True

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    position = atapi.ATFieldProperty('position')

    resume = atapi.ATFieldProperty('resume')

    eon = atapi.ATFieldProperty('eon')

    polity = atapi.ATFieldProperty('polity')

    born = atapi.ATFieldProperty('born')

    mail = atapi.ATFieldProperty('mail')

    phone = atapi.ATFieldProperty('phone')

    salary = atapi.ATFieldProperty('salary')

    sex = atapi.ATFieldProperty('sex')

    name = atapi.ATFieldProperty('name')


atapi.registerType(lookjob, PROJECTNAME)
